package com.scnu409.fragment;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.scnu409.mimicontact.R;
import com.scnu409.utils.TestContent;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class TimeRouteFragment extends Fragment {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View time_list = inflater.inflate(R.layout.time_route, container,
				false);

		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

		for (int i = 0; i < TestContent._name.length; i++) {
			Map<String, Object> item = new HashMap<String, Object>();
			item.put("user_img", TestContent._simpleImage[i]);
			item.put("time", "3月" + String.valueOf(1 + i) + "日");
			item.put("address", "华师西" + String.valueOf(i % 6));
			list.add(item);
		}

		SimpleAdapter adapter = new SimpleAdapter(getActivity(), list,
				R.layout.time_route_content, new String[] { "user_img", "time",
						"address" }, new int[] { R.id.user_img, R.id.time,
						R.id.address });
		
		ListView listView=(ListView)time_list.findViewById(R.id.time_route);
		listView.setAdapter(adapter);
		return time_list;
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
	}
}
